Skip to content

fix: handle tab on tmux next3.6 #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix: handle tab on tmux next3.6 #3

wants to merge 1 commit into from

Conversation

ddzero2c
Copy link
Owner

@ddzero2c ddzero2c commented May 12, 2025

merge this after tmux 3.6 released

@ddzero2c ddzero2c requested a review from Copilot May 12, 2025 07:47
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes tab handling in tmux-easymotion by updating the functions that compute character widths and true positions.

  • Added a new helper function calculate_tab_width and updated get_char_width, get_string_width, and get_true_position to account for tab characters.
  • Extended tests in test_easymotion.py to verify the updated handling of tabs.
  • Updated documentation in CLAUDE.md to reflect recent changes.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test_easymotion.py New tests to verify tab width and true position with tab characters.
easymotion.py Updated tab handling by refactoring character width, string width, and true position calculations; added calculate_tab_width.
CLAUDE.md Updated documentation for project guidance.
Comments suppressed due to low confidence (1)

easymotion.py:562

  • The visual position calculation code in the CASE_SENSITIVE and non-case-sensitive branches of find_matches is duplicated. Consider refactoring this logic into a separate helper function to reduce repetition and improve maintainability.
if CASE_SENSITIVE:

Comment on lines +223 to +227
"""Get visual width of a single character with caching

Args:
char: The character to measure
position: The visual position of the character (needed for tabs)
Copy link
Preview

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] It may be beneficial to update the docstring of get_char_width to explicitly mention how the position parameter affects tab width calculation and caching behavior.

Suggested change
"""Get visual width of a single character with caching
Args:
char: The character to measure
position: The visual position of the character (needed for tabs)
"""Get visual width of a single character with caching.
This function calculates the visual width of a character, taking into account
special cases like tab characters and wide East Asian characters. The result
is cached to improve performance for repeated calls with the same arguments.
Args:
char: The character to measure.
position: The visual position of the character in the line. This is used
to calculate the width of tab characters (`\t`) based on their position,
as tab width depends on alignment. Different `position` values will
result in different cache keys, which can affect performance and memory
usage.
Returns:
The visual width of the character.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant